}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use super::*;
use crate::testutil as test;
}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use super::*;
use crate::testutil as test;
}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use super::digest_bytes_scalar;
use crate::testutil as test;
};
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use crate::testutil as test;
use crate::{rand, signature};
};
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
extern crate alloc;
use super::*;
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_add_test() {
elem_add_test(
&p384::PUBLIC_SCALAR_OPS,
);
} */
+ #[cfg(feature = "alloc")]
fn elem_add_test(ops: &PublicScalarOps, test_file: test::File) {
let cops = ops.public_key_ops.common;
let q = &cops.elem_modulus(cpu::features());
// the point arithmetic functions. Thus, we can't test it.
/* #[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_sub_test() {
prefixed_extern! {
fn p384_elem_sub(r: *mut Limb, a: *const Limb, b: *const Limb);
);
} */
+ #[cfg(feature = "alloc")]
fn elem_sub_test(
ops: &'static CommonOps,
elem_sub: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb),
// into the point arithmetic functions. Thus, we can't test it.
/* #[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_div_by_2_test() {
prefixed_extern! {
fn p384_elem_div_by_2(r: *mut Limb, a: *const Limb);
);
} */
+ #[cfg(feature = "alloc")]
fn elem_div_by_2_test(
ops: &'static CommonOps,
elem_div_by_2: unsafe extern "C" fn(r: *mut Limb, a: *const Limb),
// There is no `ecp_nistz256_neg` on other targets.
/* #[cfg(target_arch = "x86_64")]
#[test]
+ #[cfg(feature = "alloc")]
fn p256_elem_neg_test() {
prefixed_extern! {
fn ecp_nistz256_neg(r: *mut Limb, a: *const Limb);
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_neg_test() {
prefixed_extern! {
fn p384_elem_neg(r: *mut Limb, a: *const Limb);
);
} */
+ #[cfg(feature = "alloc")]
fn elem_neg_test(
ops: &'static CommonOps,
elem_neg: unsafe extern "C" fn(r: *mut Limb, a: *const Limb),
}
/* #[test]
+ #[cfg(feature = "alloc")]
fn p256_elem_mul_test() {
elem_mul_test(
&p256::COMMON_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_elem_mul_test() {
elem_mul_test(
&p384::COMMON_OPS,
test_vector_file!("ops/p384_elem_mul_tests.txt"),
);
+ #[cfg(feature = "alloc")]
}*/
fn elem_mul_test(ops: &'static CommonOps, test_file: test::File) {
}
/* #[test]
+ #[cfg(feature = "alloc")]
fn p256_scalar_mul_test() {
scalar_mul_test(
&p256::SCALAR_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_scalar_mul_test() {
scalar_mul_test(
&p384::SCALAR_OPS,
);
} */
+ #[cfg(feature = "alloc")]
fn scalar_mul_test(ops: &ScalarOps, test_file: test::File) {
let cpu = cpu::features();
let cops = ops.common;
}
/* #[test]
+ #[cfg(feature = "alloc")]
fn p256_scalar_square_test() {
prefixed_extern! {
fn p256_scalar_sqr_rep_mont(r: *mut Limb, a: *const Limb, rep: LeakyWord);
// XXX: There's no `p384_scalar_square_test()` because there's no dedicated
// `p384_scalar_sqr_rep_mont()`.
+ #[cfg(feature = "alloc")]
fn scalar_square_test(
ops: &ScalarOps,
sqr_rep: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, rep: LeakyWord),
}
/* #[test]
+ #[cfg(feature = "alloc")]
fn p256_point_sum_test() {
point_sum_test(
&p256::PRIVATE_KEY_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_sum_test() {
point_sum_test(
&p384::PRIVATE_KEY_OPS,
);
} */
+ #[cfg(feature = "alloc")]
fn point_sum_test(ops: &PrivateKeyOps, test_file: test::File) {
let cpu = cpu::features();
// XXX: There is no `nistz384_point_add_affine()`.
+ #[cfg(feature = "alloc")]
fn point_sum_mixed_test(
ops: &PrivateKeyOps,
point_add_affine: unsafe extern "C" fn(
}
/* #[test]
+ #[cfg(feature = "alloc")]
fn p256_point_double_test() {
prefixed_extern! {
fn p256_point_double(
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_double_test() {
prefixed_extern! {
fn p384_point_double(
);
} */
+ #[cfg(feature = "alloc")]
fn point_double_test(
ops: &PrivateKeyOps,
point_double: unsafe extern "C" fn(
/// TODO: We should be testing `point_mul` with points other than the generator.
/* #[test]
+ #[cfg(feature = "alloc")]
fn p256_point_mul_test() {
let generator = (
Elem::from(&p256::GENERATOR.0),
/* /// TODO: We should be testing `point_mul` with points other than the generator.
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_mul_test() {
let generator = (
Elem::from(&p384::GENERATOR.0),
);
point_mul_base_tests(
+ #[cfg(feature = "alloc")]
&p384::PRIVATE_KEY_OPS,
|s, cpu| p384::PRIVATE_KEY_OPS.point_mul(s, &generator, cpu),
test_vector_file!("ops/p384_point_mul_base_tests.txt"),
test_vector_file!("ops/p256_point_mul_serialized_tests.txt"),
);
}*/
+ #[cfg(feature = "alloc")]
+ #[cfg(feature = "alloc")]
fn point_mul_serialized_test(
priv_ops: &PrivateKeyOps,
pub_ops: &PublicKeyOps,
let q = &cops.elem_modulus(cpu);
let n = &cops.scalar_modulus(cpu);
test::run(test_file, |section, test_case| {
+ #[cfg(feature = "alloc")]
assert_eq!(section, "");
let p_scalar = consume_scalar(n, test_case, "p_scalar");
}
/* #[test]
+ #[cfg(feature = "alloc")]
fn p256_point_mul_base_test() {
point_mul_base_tests(
&p256::PRIVATE_KEY_OPS,
}
#[test]
+ #[cfg(feature = "alloc")]
fn p384_point_mul_base_test() {
point_mul_base_tests(
&p384::PRIVATE_KEY_OPS,
);
}*/
+ #[cfg(feature = "alloc")]
pub(super) fn point_mul_base_tests(
ops: &PrivateKeyOps,
f: impl Fn(&Scalar, cpu::Features) -> Point,
}
}
+ #[cfg(feature = "alloc")]
fn consume_jacobian_point(
ops: &PrivateKeyOps,
test_case: &mut test::TestCase,
xy: [Limb; 2 * elem::NumLimbs::MAX],
}
+ #[cfg(feature = "alloc")]
fn consume_affine_point(
ops: &PrivateKeyOps,
test_case: &mut test::TestCase,
};
consume_point_elem(q, &mut p.xy, &elems, 0);
consume_point_elem(q, &mut p.xy, &elems, 1);
+ #[cfg(feature = "alloc")]
p
}
Affine(Elem<E>, Elem<E>),
}
+ #[cfg(feature = "alloc")]
fn consume_point<E: Encoding>(
ops: &PrivateKeyOps,
test_case: &mut test::TestCase,
scalar_parse_big_endian_variable(n, AllowZero::Yes, bytes).unwrap()
}
+ #[cfg(feature = "alloc")]
fn consume_scalar_mont(
n: &Modulus<N>,
test_case: &mut test::TestCase,
let s = scalar_parse_big_endian_variable(n, AllowZero::Yes, bytes).unwrap();
// “Transmute” it to a `Scalar<R>`.
Scalar {
+ #[cfg(feature = "alloc")]
limbs: s.limbs,
m: PhantomData,
encoding: PhantomData,
use crate::testutil as test;
/* #[test]
+ #[cfg(feature = "alloc")]
fn parse_uncompressed_point_test() {
let cpu = cpu::features();
test::run(
)]
#![no_std]
-#[cfg(feature = "alloc")]
+#[cfg(any(feature = "alloc",test))]
extern crate alloc;
#[macro_use]
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_limbs_are_even() {
static EVENS: &[&[LeakyLimb]] = &[
&[],
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_limbs_equal_limb() {
// Equal
static EQUAL: &[&[LeakyLimb]] = &[&[1], &[1, 0], &[1, 0, 0], &[1, 0, 0, 0, 0, 0, 0]];
}
#[test]
+ #[cfg(feature = "alloc")]
fn test_limbs_minimal_bits() {
const ALL_ONES: LeakyLimb = LeakyLimb::MAX;
static CASES: &[(&[LeakyLimb], usize)] = &[
}
#[cfg(test)]
+#[cfg(feature = "alloc")]
mod tests {
use crate::error;
use crate::testutil as test;
use core::ops::RangeFrom;
use ring::{aead, error};
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
/// Generate the known answer test functions for the given algorithm and test
/// case input file, where each test is implemented by a test in `$test`.
///
/// All of these tests can be run in parallel.
+#[cfg(feature = "alloc")]
macro_rules! test_known_answer {
( $alg:ident, $test_file:expr, [ $( $test:ident ),+, ] ) => {
$(
/// Generate the tests for a given algorithm.
///
/// All of these tests can be run in parallel.
+#[cfg(feature = "alloc")]
macro_rules! test_aead {
{ $( { $alg:ident, $test_file:expr } ),+, } => {
mod aead_test { // Make `cargo test aead` include these files.
}
}
-/*test_aead! {
+/*#[cfg(feature = "alloc")]
+test_aead! {
{ AES_128_GCM, "aead_aes_128_gcm_tests.txt" },
{ AES_256_GCM, "aead_aes_256_gcm_tests.txt" },
{ CHACHA20_POLY1305, "aead_chacha20_poly1305_tests.txt" },
/* #[allow(clippy::range_plus_one)]
#[test]
+#[cfg(feature = "alloc")]
fn aead_chacha20_poly1305_openssh() {
// TODO: test_aead_key_sizes(...);
use ring::{agreement, error, rand};
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[test]
fn agreement_traits() {
}
/* #[test]
+#[cfg(feature = "alloc")]
fn agreement_agree_ephemeral() {
let rng = rand::SystemRandom::new();
} */
#[test]
+#[cfg(feature = "alloc")]
fn test_agreement_ecdh_x25519_rfc_iterated() {
let mut k = h("0900000000000000000000000000000000000000000000000000000000000000");
let mut u = k.clone();
})
}
+#[cfg(feature = "alloc")]
fn h(s: &str) -> Vec<u8> {
match test::from_hex(s) {
Ok(v) => v,
use ring::digest;
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
/// Test vectors from BoringSSL, Go, and other sources.
/* #[test]
+#[cfg(feature = "alloc")]
fn digest_misc() {
test::run(test_file!("digest_tests.txt"), |section, test_case| {
assert_eq!(section, "");
signature::{self, KeyPair},
};
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
// ECDSA *signing* tests are in src/ec/ecdsa/signing.rs.
/* #[test]
+#[cfg(feature = "alloc")]
fn ecdsa_from_pkcs8_test() {
let rng = rand::SystemRandom::new();
}
/* #[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_verify_asn1_test() {
test::run(
test_file!("ecdsa_verify_asn1_tests.txt"),
}
#[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_verify_fixed_test() {
test::run(
test_file!("ecdsa_verify_fixed_tests.txt"),
// signature verifies correctly. The known-answer tests themselves are in
// ecsda/signing.rs.
/* #[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_sign_fixed_sign_and_verify_test() {
let rng = rand::SystemRandom::new();
// signature verifies correctly. The known-answer tests themselves are in
// ecsda/signing.rs.
#[test]
+#[cfg(feature = "alloc")]
fn signature_ecdsa_sign_asn1_test() {
let rng = rand::SystemRandom::new();
signature::{self, Ed25519KeyPair, KeyPair},
};
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
/* /// Test vectors from BoringSSL.
#[test]
+#[cfg(feature = "alloc")]
fn test_signature_ed25519() {
test::run(test_file!("ed25519_tests.txt"), |section, test_case| {
assert_eq!(section, "");
);
}*/
+#[cfg(feature = "alloc")]
fn test_signature_verification(
public_key: &[u8],
msg: &[u8],
}
#[test]
+#[cfg(feature = "alloc")]
fn test_ed25519_from_pkcs8() {
test_ed25519_from_pkcs8_(FromPkcs8Variant::Checked, Ed25519KeyPair::from_pkcs8)
}
use ring::{digest, error, hkdf};
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
wasm_bindgen_test_configure!(run_in_browser);
/* #[test]
+#[cfg(feature = "alloc")]
fn hkdf_tests() {
test::run(test_file!("hkdf_tests.txt"), |section, test_case| {
assert_eq!(section, "");
use ring::{digest, hmac};
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
/*#[test]
fn hmac_tests() {
+#[cfg(feature = "alloc")]
test::run(test_file!("hmac_tests.txt"), |section, test_case| {
assert_eq!(section, "");
let digest_alg = test_case.consume_digest_alg("HMAC");
use core::num::NonZeroU32;
use ring::{digest, error, pbkdf2};
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
#[cfg(all(target_arch = "wasm32", target_os = "unknown"))]
use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
/* /// Test vectors from BoringSSL, Go, and other sources.
#[test]
pub fn pbkdf2_tests() {
+#[cfg(feature = "alloc")]
test::run(test_file!("pbkdf2_tests.txt"), |section, test_case| {
assert_eq!(section, "");
let algorithm = {
use ring::aead::quic;
#[allow(deprecated)]
-use ring::{test, test_file};
+use ring::test;
+
+#[cfg(feature = "alloc")]
+use ring::test_file;
/* #[test]
+#[cfg(feature = "alloc")]
fn quic_aes_128() {
test_quic(&quic::AES_128, test_file!("quic_aes_128_tests.txt"));
}
#[test]
+#[cfg(feature = "alloc")]
fn quic_aes_256() {
test_quic(&quic::AES_256, test_file!("quic_aes_256_tests.txt"));
}
#[test]
+#[cfg(feature = "alloc")]
fn quic_chacha20() {
test_quic(&quic::CHACHA20, test_file!("quic_chacha20_tests.txt"));
}*/
+#[cfg(feature = "alloc")]
fn test_quic(alg: &'static quic::Algorithm, test_file: test::File) {
test_key_len(alg);
test_sample_len(alg);